let list = document.querySelector('.list')
// 鼠标右键时显示ul
document.oncontextmenu = function () {
  list.style.display = 'block'
  return false
}
// 文档上点击元素时，隐藏ul
document.onclick = function () {
  list.style.display = 'none'
}

let li = document.querySelectorAll('.list>li')
for (let i = 0; i < li.length; i++) {
  let item = li[i]
  item.onclick = function (e) {
    console.log(item.innerHTML)
    // 阻止事件冒泡，不会触发到document的onclick事件
    e.stopPropagation()
  }
}
